package cn.com.bluemoon.daps.common.sql.layer;

import java.util.HashMap;
import java.util.Map;

/**
 * Sql语法解析工厂
 *
 * @author Jarod.Kong
 * @date 2021/1/21 15:34
 */
public class LayerCheckFactory {
    public static final String LAYER_DRUID = "druid";
    public static final String LAYER_JSQLPARSER = "jsqlparser";

    private static final Map<String, ILayerCheck> LAYERS = new HashMap<String, ILayerCheck>() {{
        put(LAYER_DRUID, new DruidLayerCheck());
        put(LAYER_JSQLPARSER, new JSqlParserLayerCheck());
    }};

    /**
     * 默认语法解析器
     *
     * @return
     */
    public static ILayerCheck type() {
        return LAYERS.get(LAYER_DRUID);
    }

    /**
     *
     * @param type
     * @return
     */
    public static ILayerCheck type(String type) {
        return LAYERS.getOrDefault(type, type());
    }


}
